package com.lch.base.http.config;

import android.content.Context;

import java.io.File;

import okhttp3.Cache;

/**
 * BaseResult类型的callback，解析数据，可以自定义处理结果
 *
 * @author lee(29487113@qq.com) on 18/2/4
 */
public class CacheProvide {
    public static final String CACHE_TIME = "CacheTime"; //设置请求头的名字 统一名称
    private static final String CACHE_FILE_NAME = "okHttpCahe"; //cache缓存文件名
    private static final long CACHE_MAX_SIZE = 1024 * 1024 * 10; //cache缓存大小 10M

    public enum CACHE_TYPE {
        CACHE_NONE,
        CACHE_SERVER,
        CACHE_CLIENT
    }

    public static Cache provideCache(Context context) {
        File cacheFile = new File(context.getCacheDir(), CACHE_FILE_NAME); //google建议放到这里
        return new Cache(cacheFile, CACHE_MAX_SIZE);
    }
}
